package cn.com.dycc.util;

import java.io.IOException;
import java.util.Properties;
/**
 * 加载数据库驱动，读取配置文件类
 * @author Administrator
 *
 */
public class PropertiesUtil {
	public static String readProperties(String str) throws IOException{
		Properties p = new Properties();
		p.load(PropertiesUtil.class.getClassLoader().getResourceAsStream("db/db.properties"));
		str = p.getProperty(str);
		return str;
	}
	
	/**
	 * 读取properties文件的某字段值
	 * @param file_path properties文件路径
	 * @param str 字段名称
	 * @return 字段值
	 * @throws IOException
	 * @author gaofan
	 */
	public static String readProperties(String file_path,String str) throws IOException{
		Properties p = new Properties();
		p.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(file_path));
		str = p.getProperty(str);
		return str;
	}
	
	public static void main(String[] args) throws IOException {
		String size = readProperties("restPassword");
		System.out.println(size);
	}
}
